package com.qj.daibei.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qj.daibei.mapper.OverdueMapper;
import com.qj.daibei.pojo.Overdue;
import com.qj.daibei.service.OverdueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * author wml
 * Created on 2021/10/28 20:52
 */
@Service
public class OverdueServiceImpl implements OverdueService {

    @Autowired
    private OverdueMapper overdueMapper;

    @Override
    public List<Overdue> findOverdueAndShouldPayBack(Integer userId) {
        return this.overdueMapper.findOverdueAndShouldPayBack(userId);
    }

    @Override
    public PageInfo<Overdue> findOverdueAndShouldPayBackByPage(int pageNum, Integer userId) {
        PageHelper.startPage(pageNum, 6);
        List<Overdue> overdueList = this.overdueMapper.findOverdueAndShouldPayBack(userId);
        PageInfo<Overdue> pageInfo = new PageInfo<>(overdueList, 5);
        return pageInfo;
    }

    @Override
    public int insertOverdueByBatch(List<Overdue> list) {
        return this.overdueMapper.insertOverdueByBatch(list);
    }

    @Override
    public int updateOverdueById(Overdue overdue) {
        return this.overdueMapper.updateOverdueById(overdue);
    }
}
